package com.run.cat.api.controller;


import com.run.cat.common.base.BaseResult;
import com.run.cat.dao.entity.Topic;
import com.run.cat.service.ITopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 话题表 前端控制器
 * </p>
 *
 * @author CG
 * @since 2020-08-19
 */
@Controller
@RequestMapping("/topic")
public class TopicController {

    @Autowired
    private ITopicService topicService;

    @RequestMapping("/list")
    @ResponseBody
    public BaseResult list(){
        return BaseResult.successData(topicService.queryOne(new Topic()));
    }

    @RequestMapping("/add")
    @ResponseBody
    public BaseResult add(@RequestBody Topic topic){
        topicService.insert(topic);
        return BaseResult.success();
    }

}
